package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpExpr;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface EmpMapper {

//    /**
//     * 查询总记录数
//     * @return
//     */
//    @Select("select count(*) from emp e")
//    Long count();

//    /**
//     * 分页查询
//     * @param start
//     * @param pageSize
//     * @return
//     */
//    @Select("select e.*, d.name deptName " +
//            "from emp as e left join dept as d on e.dept_id = d.id " +
//            "limit #{start}, #{pageSize}")
//    List<Emp> Page(Integer start, Integer pageSize);

    /**
     * 查询所有的员工及其对应的部门名称
     */
    //@Select("select e.*, d.name deptName from emp as e left join dept as d on e.dept_id = d.id")
    List<Emp> list(EmpQueryParam empQueryParam);


    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) values " +
            "(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    void EmpDelete(List<Integer> ids);

    @Select("select * from emp where id = #{id}")
    Emp selectEmpById(Integer id);

    void EmpUpdate(Emp emp);

    Emp SelectEmpExprById(Integer id);

    @Select("select * from emp")
    List<Emp> MasterList();
}
